package net.sunbeta.test.control;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AddServlet extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String a = req.getParameter("a");
		String b = req.getParameter("b");

		if (a == null || b == null) {
			resp.setStatus(400);
			return;
		}

		int result = Integer.parseInt(a) + Integer.parseInt(b);

		resp.setStatus(200);
		resp.getWriter().print(result);
	}
}